package registnet.records.source;

import registnet.records.Curriculum;
import registnet.records.Student;

public class StudentSource {

	private String studentNumber;
	private Student student;
	
	
	/**
	 * Default constructor
	 * 
	 * @param studentNumber - The student number assigned to a student
	 */
	public StudentSource(String studentNumber){
		this.studentNumber = studentNumber;
		this.load();
	}
	
	
	/**
	 * Loads data from source
	 */
	public void load(){
		try{
			registnet.dao.Student DAOStudent = new registnet.dao.StudentPeer().getStudent(this.studentNumber);
			Curriculum curriculum = new CurriculumSource(DAOStudent.getCurriculum().getCurriculumCode()).getCurriculum();
			this.student = new Student(this.studentNumber);
			this.student.setFirstName(DAOStudent.getFirstName());
			this.student.setMiddleName(DAOStudent.getMiddleName());
			this.student.setLastName(DAOStudent.getLastName());
			this.student.setSex(DAOStudent.getSex());
			this.student.setCurriculum(curriculum);
		}catch(Exception e){
			e.printStackTrace();
		}
	}
	
	
	/**
	 * Gets the student
	 * 
	 * @return The student
	 */
	public Student getStudent(){
		return this.student;
	}
	
}
